module(..., package.seeall)

originLevel = nil;

new = function ()
	localGroup = display.newGroup();	
	print("GamePauseScreen");
	local myText = display.newText("Game Paused", 0, 0, native.systemFont, 16)
	myText:setTextColor(255, 255, 255)
	localGroup:insert(myText);
	
	local menuButton = display.newImageRect("menu.png", 64, 64);
	menuButton.id = "menu";
	menuButton.x = 120;
	menuButton.y = 50;
	
	
	local backButton = display.newImageRect("back.png", 256, 256);
	backButton.id = "back";
	backButton.x = 50;
	backButton.y = 50;
	backButton.xScale = 0.2;
	backButton.yScale = 0.2;	

	localGroup:insert(backButton);
		 
	local function listener(event) 
		if (event.phase == "ended") then			
			if (event.target.id == "menu") then
				director:changeScene("GameLevelSelect", "crossfade");
			end
			if (event.target.id == "back") then
				director:changeScene(originLevel, "crossfade");
			end
		end
		return true 
	end
 	
	backButton:addEventListener("touch", listener);
	menuButton:addEventListener("touch", listener);
	
	return localGroup;	
end

function setOriginLevel(level)
	originLevel = level;
	print("Origin level seted to " .. originLevel)
end

